<?php namespace Summer\Hjd\Models;

use Model;
use Config;

/**
 * Model
 */
class TfRuleModel extends Model
{
    use \Winter\Storm\Database\Traits\Validation;
    

    /**
     * @var string The database table used by the model.
     */
    public $table = 'summer_hjd_tf_rule';

    /**
     * @var array Validation rules
     */
    public $rules = [
        'from_currency_slug' => 'required|between:2,255',
        'to_currency_slug' => 'required|between:2,255',
        'tf_type' => 'required',
    ];
    public $belongsTo = [
        'from_currency' => ['Summer\Hjd\Models\CurrencyModel', 'key' => 'from_currency_slug', 'otherKey' => 'slug'],
        'to_currency' => ['Summer\Hjd\Models\CurrencyModel', 'key' => 'to_currency_slug', 'otherKey' => 'slug']
    ];

    public function getFromCurrencySlugOptions()
    {
        return CurrencyModel::where('status',1)->pluck('title','slug');
    }

    public function getToCurrencySlugOptions()
    {
        return CurrencyModel::where('status',1)->pluck('title','slug');
    }
    public function getTfTypeOptions()
    {
        return Config::get('summer.hjd::tf_type');
    }


}
